/*
 * @Author: your name
 * @Date: 2021-08-06 00:22:34
 * @LastEditTime: 2021-08-08 21:17:54
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /chaos_alpha/src/common/template/Single.h
 */
#pragma once
#include <assert.h>

template <typename T>
class Single
{
public:
	static T& Instance()
	{
		static T s_instance;
		return s_instance;
	}

	virtual ~Single() {}

protected:
	Single() {}
};


//thread local single
template <typename T>
class ThreadSingle
{
public:
	static T& Instance()
	{
#ifdef WIN32
		static __declspec(thread) T s_instance;
		return s_instance;
#else
		static __thread T s_instance;
		return s_instance;
#endif
	}

	virtual ~ThreadSingle() {}

protected:
	ThreadSingle() {}
};